package com.tgg.treeproject.utils;


import com.tgg.treeproject.pojo.TreeData;

import java.util.ArrayList;
import java.util.List;

public class TreeMenuUtil {

    public static List<TreeData> getTreeMenuList(List<TreeData> menuList, String parentId) {
        List<TreeData> resultList = new ArrayList<>();
        for (TreeData menu : menuList) {
            if (parentId.equals(menu.getPId())) {
                List<TreeData> children = getTreeMenuList(menuList, menu.getId());
                menu.setChildren(children);
                resultList.add(menu);
            }
        }
        return resultList;
    }
}
